<?php
/**
 * PC 端 首页尾部控制器
 * indexfootercontroller.php
 * 
 * Create on 2015-4-10 17:21:29
 * Create by Jim.Chou
 */
namespace haibao\cms\business\control\pc\common;
use \haibao\cms\model\filter\link as LinkFilter;
use \haibao\cms\business\Link as LinkBusiness;
use haibao\frame\data\query\Condition;

class IndexFooterController extends \haibao\cms\business\control\Base{
	
	public function __construct($updateTime = null,$controlId,$isPublish){
		parent::__construct($updateTime,$controlId,$isPublish);
	}
	
	
	/**
	 * 获取模版内容
	 * @param : String $content
	 */
	public function displayTemplateHtml(){

		$controlData = $this->getParameter(self::$CONTROL_DATA);
		$content = $this->getParameter(self::$CONTROL_CONTENT);
		$path = $this->generateHtmlPath(__CLASS__);
		$parameters = array();
		if($controlData['auto']){
			foreach($controlData['auto'] as $data){
				$parameterValue = json_decode($data['ParameterValue']);
				array_push($parameters,$parameterValue);
			}
		}
		$rowNum = isset($parameters[0])?$parameters[0]->limit:10;		
		$linkFilter = new LinkFilter();
		$linkBusiness = new LinkBusiness();
		$linkFilter->select(array
			(
				LinkFilter::CONDITION_FIELD_NAME_LINK_NAME,
					LinkFilter::CONDITION_FIELD_NAME_URL
			)
		);
		$linkFilter->where(LinkFilter::CONDITION_FIELD_NAME_IS_SHOW_WEB,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Link::IS_SHOW_WEB_YES);
		$linkFilter->where(LinkFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Link::DEFAULT_STATUS_OK);
		$linkFilter->order(LinkFilter::CONDITION_FIELD_NAME_CREATE_TIME,false);		
		$linkList = $linkBusiness->getLinkList($linkFilter);
		$counter = $key = 0;
		$linkArr = array();
		foreach($linkList as $list){
			$counter = $counter == $rowNum ? 0 : $counter;
			$linkArr[$key][$counter]["linkName"] = $list->LinkName;
			$linkArr[$key][$counter]["url"] = $list->Url;
			$counter++;
			if($counter == $rowNum){$key++;}
		}
		$this->assign('linkArr',$linkArr);
		$domainHost = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_DOMAIN);
		$this->assign('staticHost', $domainHost);
		$this->generateHtml($path,$content);
		return $this->getHtml($path);
	}
}